package com.lwm.controller;

import com.lwm.domain.DeliveryOrder;
import com.lwm.domain.ResponseResult;
import com.lwm.dto.DeliveryOrderDto;
import com.lwm.service.impl.DeliveryOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/deliveryOrder")
public class DeliveryOrderController {
    @Resource
    private DeliveryOrderService deliveryOrderService;

    /**
     * 收到分页
     *
     * @param deliveryOrderDto 交货订单dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/page")
    public ResponseResult getPage(@RequestBody DeliveryOrderDto deliveryOrderDto) {
        return deliveryOrderService.getPage(deliveryOrderDto);
    }

    /**
     * 添加
     *
     * @param deliveryOrder 交货订单
     * @return {@link ResponseResult}
     */
    @PostMapping
    public ResponseResult save(@RequestBody DeliveryOrder deliveryOrder) {
        return deliveryOrderService.save(deliveryOrder);
    }

    /**
     * 更新
     *
     * @param deliveryOrder 交货订单
     * @return {@link ResponseResult}
     */
    @PutMapping
    public ResponseResult update(@RequestBody DeliveryOrder deliveryOrder) {
        return deliveryOrderService.updateById(deliveryOrder);
    }

    /**
     * 删去
     *
     * @param ids ids
     * @return {@link ResponseResult}
     */
    @DeleteMapping("/{ids}")
    public ResponseResult delete(@PathVariable List<Long> ids) {
        return deliveryOrderService.removeBatch(ids);
    }
    @GetMapping("/all")
    public ResponseResult getAll() {
        return deliveryOrderService.getAll();
    }
}
